Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pluginhub: add endpoints for generating shields.io badges #4

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

TheStonedTurtle
Copy link
Contributor

Adds two new endpoints to the pluginhub portion of the API which can be used with https://shields.io to generate README badges for Github pages. These endpoints would be used with the Endpoint Badges portion of the shields.io website (https://shields.io/badges/endpoint-badge)

I'm not sure if this is actually feasible within this API as the runlite-{version} part will change with every release but I figured I'd PR it anyway. Maybe the API can support latest-release as a version to support this PR? If not feel free to close this.

  1. /shields/installs/plugin/{pluginName}
  2. /shields/rank/plugin/{pluginName}

Example shields.io format (assuming latest-release would work):
https://img.shields.io/endpoint?url=https://api.runelite.net/latest-release/pluginhub/shields/installs/plugin/quest-helper

I copied these URL paths from my personal website, if they are too verbose let me know and I can change them.

I was able to test this functionality through IntelliJ Ultimate Edition. I used the below generated-requests.http file to populate dummy data:

###
POST http://localhost:8080/pluginhub
Content-Type: application/json
X-Forwarded-For: 127.0.0.1

["test", "test1"]

###
POST http://localhost:8080/pluginhub
Content-Type: application/json
X-Forwarded-For: 127.0.0.2

["test", "test2"]

###
POST http://localhost:8080/pluginhub
Content-Type: application/json
X-Forwarded-For: 127.0.0.3

["test", "test3"]

###
POST http://localhost:8080/pluginhub
Content-Type: application/json
X-Forwarded-For: 127.0.0.4

["test", "test4"]

###
POST http://localhost:8080/pluginhub
Content-Type: application/json
X-Forwarded-For: 127.0.0.5

["test", "test5"]

pluginhub endpoint (unchanged)
image

plugin value exists:
image
image

plugin value does not exist:
image
image

long rank = pluginCounts.getOrDefault(pluginName, -1L);
if (rank != -1)
{
List<Map.Entry<String, Long>> orderedEntries = pluginCounts.entrySet().stream()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of sorting + counting to get the rank, you can just count the number of plugins with more installs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented your change, now plugins with the same install count will share a rank.
image
image

@Adam- Adam- merged commit d9e623f into runelite:master Mar 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants